#! /usr/bin/perl

#-------------------------------------------------------------------------------
#--
#-- Module      :  PackageRebuilder
#-- Copyright   :  (c) Lakshmi Narasimhan T V
#-- License     :  GNU GPLv3
#--
#-- Maintainer  :  <lakshminaras2002 at gmail dot com>
#-- Stability   :  provisional
#-- Portability :  portable
#--
#--
#--
#---------------------------------------------------------------------------------

use strict;
use warnings;
use File::Basename;

my $PROG_DIR;

BEGIN
{
my $TEMP_DIR = File::Basename::dirname($0);
$PROG_DIR = abs_path($TEMP_DIR);
push @INC,$PROG_DIR;
}

sub run_build_script($$$)
{
  my $specfile_path = shift;
  my $shell_script = shift;
  my $commit_msg = shift;
  my $specfile_basedir = stripws(`dirname $specfile_path`);
  my $specfile_name = stripws(`basename $specfile_path`);
  if(system("cd $specfile_basedir && sh $shell_script $specfile_name") !=0)
  # || system("cd $specfile_basedir && fedpkg add $specfile_name") != 0
  # || system("cd $specfile_basedir && fedpkg commit -msg $commit_msg") != 0
  # || system("cd $specfile_basedir && fedpkg push") !=0
  # || system("cd $specfile_basedir && fedpkg build") != 0)
  {
    return 0;
  }
  else
  {
    system("sleep 600");
    return 1;
  }
}

1;